import request from '@/utils/request'

export const exerciseApi = {
    generateExercises(subject, grade, topic, count) {
        return request({
            url: '/api/exercises/generate',
            method: 'post',
            params: {
                subject,
                grade,
                topic,
                count
            }
        });
    },
    
    getExerciseHistory(page = 1) {
        // 固定每页15条
        const size = 15;
        
        // 添加时间戳避免缓存问题
        const timestamp = new Date().getTime();
        console.log(`发起历史记录请求：页码=${page}, 大小=${size}, 时间戳=${timestamp}`);
        
        return request({
            url: `/api/exercises/history?_t=${timestamp}`,
            method: 'get',
            params: {
                teacherId: localStorage.getItem('teacherId'),
                page,
                size
            }
        });
    }
}; 